<template>
    <container type="top-header" :show="{header:formShow}" class="g-width100 g-height100" header-style="height:auto;" main-style="padding:0;">
        <Form slot="header" inline
              submit-bus-key="CustomerManageList"
              :form-items="formItems"
              :layout="[4,3]"
              :layout-col-max="6"
              label-width="100px"
        ></Form>
        <Table slot="main"
               ref="table"
               form-submit-bus-key="CustomerManageList"
               :columns="columns"
               :operations="tableOperations"
               unique-label="name"
               v-on:toolbarSearchClick="formShow = !formShow"
        ></Table>
    </container>
</template>

<script>
    import Container from '../../../../common-util/src/components/page/Container.vue'
    import Form from '../../../../common-util/src/components/page/Form.vue'
    import Table from '../../../../common-util/src/components/page/Table.vue'

    export default {
        components:{
            Form,
            Table,
            Container
        },
        data(){
            return {
                formShow: true,
                formItems:[
                    {
                        field: {
                            name: 'code'
                        },
                        element:{
                            label: '客户编号',
                        }
                    },
                    {
                        field: {
                            name: 'appellation'
                        },
                        element:{
                            label: '称呼',
                        }
                    },
                    {
                        field: {
                            name: 'name'
                        },
                        element:{
                            label: '真实姓名',
                        }
                    },
                    {
                        field: {
                            name: 'genderDictId'
                        },
                        element:{
                            label: '性别',
                            type: 'selectDict',
                            selectDict: {
                                groupCode: 'gender'
                            }
                        }
                    },
                    {
                        field: {
                            name: 'companyId'
                        },
                        element:{
                            label: '所在公司',
                            type: 'inputSelectTree',
                            inputSelectTree:{
                                dataUrl: this.$baseURL.crm +  '/crm/company/tree'
                            },
                        }
                    },
                    {
                        field: {
                            name: 'categoryDictId'
                        },
                        element:{
                            label: '客户来源',
                            type: 'selectDict',
                            selectDict: {
                                groupCode: 'customer_category'
                            },
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.$baseURL.crm + '/crm/customer/listPage',
                                    label: '查询'
                                },
                                {
                                    action: 'reset',
                                    label: '重置'
                                }
                            ]
                        }
                    }
                ],
                columns:[
                    {
                        prop: 'code',
                        label:'客户编号'
                    },
                    {
                        prop: 'appellation',
                        label:' 称呼'
                    },
                    {
                        prop: 'name',
                        label:'姓名'
                    },
                    {
                        prop: 'customerBelong.userNickname',
                        label:'归属人'
                    },
                    {
                        prop: 'avatar',
                        label:'头像',
                        showInDetail: true,
                        formatType: 'image'
                    },
                    {
                        prop: 'genderDictName',
                        label:'性别'
                    },
                    {
                        prop: 'age',
                        label:'年龄'
                    },
                    {
                        prop: 'birthDayTxt',
                        label:'生日',
                        showInDetail: true
                    },
                    {
                        prop: 'companyName',
                        label:'所在公司'
                    },
                    {
                        prop: 'departmentName',
                        label:'所在部门'
                    },
                    {
                        prop: 'isBlack',
                        label:'是否黑名单'
                    },
                    {
                        prop: 'blackReason',
                        label:'黑名单原因',
                        showInDetail: true
                    },
                    {
                        prop: 'howFromDictName',
                        label:'客户分类，字典'
                    },
                    {
                        prop: 'unionId',
                        label:'unionId',
                        showInDetail: true
                    },
                ],
                tableOperations:[
                    {
                        action: 'nav',
                        url:'/customer/customerAdd',
                        label: '添加'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/customer/customerEdit/:id',
                        label: '编辑'
                    },
                    {
                        action: 'detail',
                        disabledOnMissingSelect:true,
                        label: '详情'
                    },
                    {
                        action: 'delete',
                        url:this.$baseURL.crm + '/crm/customer/:id',
                        disabledOnMissingSelect:true,
                        label:'删除'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/customerContact',
                        routeQuery: (row)=>{return {customerId: row.id}},
                        label: '客户联系方式'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/customerAssociatedContactPerson',
                        routeQuery: (row)=>{return {customerId: row.id}},
                        label: '关联联系人'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/customerCredential',
                        routeQuery: (row)=>{return {customerId: row.id}},
                        label: '客户证件'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/customerTag',
                        routeQuery: (row)=>{return {customerId: row.id}},
                        label: '客户标签'
                    },
                ]
            }
        }
    }
</script>

<style scoped>

</style>